package com.rock.platform.dao;

import java.io.Serializable;
import java.sql.Connection;
import java.util.List;
import javax.persistence.EntityManager;

public abstract interface IGenericDao {
	public abstract <T, ID extends Serializable> T findByID(ID paramID,
			boolean paramBoolean, Class<T> paramClass);

	public abstract <T> List<T> findAll(Class<T> paramClass);

	public abstract <T> void add(T paramT);

	public abstract <T> void add(T[] paramArrayOfT);

	public abstract <T> T merge(T paramT);
	
	public abstract <T> void merge(T[] paramArrayOfT);

	public abstract <T> void delete(T paramT);

	public abstract <T> void delete(T[] paramArrayOfT);

	public abstract <T, ID extends Serializable> void deleteByID(ID paramID,
			Class<T> paramClass);

	public abstract <T, ID extends Serializable> void deleteByID(
			ID[] paramArrayOfID, Class<T> paramClass);

	public abstract void flush();

	public abstract void clear();

	public abstract EntityManager getEntityManager();

	public abstract Connection getConnection();
	

    /**
     * 将Connection与EntityManager相关联
     * @param connection
     */
    public void reconnect(Connection connection);
    
    /**
     * 释放Connection与EntityManager的关联
     */
    public void disconnect();
    
    /**
     * 将指定的对象从缓存中清除，同clear
     * @param <T>
     * @param entity
     */
    public <T> void evict(T entity);
}